<?php

namespace lib\Server\Http;

class Request
{
	public $header;
	public $body;
	public $method;
	public $raw_content;
	public $path_info;
	public $files;
	public $cookie;

	public function __construct($header = [], $get = [], $post = [], $raw_content = false, $files = [], $cookie = [], $server = [])
	{
		$this->header    = $header;
		$this->get       = $_GET = $get;
		$this->post      = $_POST = $post;
		$this->request   = $_REQUEST = @array_merge($get, $post, $this->cookie);
		$this->method    = $server['request_method'];
		$this->path_info = $server['path_info'];;
		$this->server      = $_SERVER = $server;
		$this->files       = $_FILES = $files;
		$this->cookie      = $_COOKIE = $cookie;
		$this->raw_content = $raw_content;
	}

	public function getRequest($key)
	{
		return @$this->request[$key] ?: null;
	}

	public function getHeader($name)
	{
		return @$this->header[$name] ?: null;
	}

	public function getRawBody()
	{
		return $this->raw_content;
	}

	public function getFiles(){
		return $this->files;
	}

	public function getCookie($name){
		return @$this->cookie[$name];
	}

}
